package com.shishuo.cms.tag;

import static freemarker.template.ObjectWrapper.BEANS_WRAPPER;

import java.io.IOException;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.shishuo.cms.entity.GoodsItemKeywordsEntity;
import com.shishuo.cms.entity.vo.PageVo;

import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;

@Service
public class GoodsSearchKeywordsTag extends BaseTagPlugin
{
	@Override
	public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException
	{
		int page = Integer.parseInt(params.get("p").toString());
		int pageSize = Integer.parseInt((params.get("pageSize")!=null)?params.get("pageSize").toString():"50");
		try {
			PageVo<GoodsItemKeywordsEntity>  pageList=goodsItemKeywordsService.getAllListPage(page,pageSize);
			env.setVariable("tag_keywords_list", BEANS_WRAPPER.wrap(pageList));
			body.render(env.getOut());
		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
}
